Skip to content

Comments

Backport subject : "bpf JIT optimization based on Zba and Zbb extension"#128

Merged
sterling-teng merged 8 commits intoRVCK-Project:rvck-6.6from
uestc-gr:bpf
Oct 22, 2025
Merged

Backport subject : "bpf JIT optimization based on Zba and Zbb extension"#128
sterling-teng merged 8 commits intoRVCK-Project:rvck-6.6from
uestc-gr:bpf

Conversation

@uestc-gr
Copy link
Contributor

@uestc-gr uestc-gr commented Sep 5, 2025

参见issue:
#127

测试方法:
使用内核自带的测试模块 test_bpf.ko 和 test_verifier, 运行相关测试用例 test_progs

@oervci
Copy link

oervci commented Sep 5, 2025

开始测试

@oervci
Copy link

oervci commented Sep 5, 2025

开始测试

@oervci
Copy link

oervci commented Sep 5, 2025

@oervci
Copy link

oervci commented Sep 5, 2025

@oervci
Copy link

oervci commented Sep 5, 2025

Lava check done! result url: https://lava.oerv.ac.cn/results/657/0_rvck_common-test_qemu

@oervci
Copy link

oervci commented Sep 8, 2025

Kernel build success!

fangyu0809 pushed a commit to fangyu0809/rvck that referenced this pull request Sep 8, 2025
commit 02c7f72 upstream.

In a filesystem with a block size larger than 4KB, the hole length
calculation for a non-extent inode in ext4_ind_map_blocks() can easily
exceed INT_MAX. Then it could return a zero length hole and trigger the
following waring and infinite in the iomap infrastructure.

  ------------[ cut here ]------------
  WARNING: CPU: 3 PID: 434101 at fs/iomap/iter.c:34 iomap_iter_done+0x148/0x190
  CPU: 3 UID: 0 PID: 434101 Comm: fsstress Not tainted 6.16.0-rc7+ RVCK-Project#128 PREEMPT(voluntary)
  Hardware name: QEMU KVM Virtual Machine, BIOS unknown 2/2/2022
  pstate: 60400005 (nZCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
  pc : iomap_iter_done+0x148/0x190
  lr : iomap_iter+0x174/0x230
  sp : ffff8000880af740
  x29: ffff8000880af740 x28: ffff0000db8e6840 x27: 0000000000000000
  x26: 0000000000000000 x25: ffff8000880af830 x24: 0000004000000000
  x23: 0000000000000002 x22: 000001bfdbfa8000 x21: ffffa6a41c002e48
  x20: 0000000000000001 x19: ffff8000880af808 x18: 0000000000000000
  x17: 0000000000000000 x16: ffffa6a495ee6cd0 x15: 0000000000000000
  x14: 00000000000003d4 x13: 00000000fa83b2da x12: 0000b236fc95f18c
  x11: ffffa6a4978b9c08 x10: 0000000000001da0 x9 : ffffa6a41c1a2a44
  x8 : ffff8000880af5c8 x7 : 0000000001000000 x6 : 0000000000000000
  x5 : 0000000000000004 x4 : 000001bfdbfa8000 x3 : 0000000000000000
  x2 : 0000000000000000 x1 : 0000004004030000 x0 : 0000000000000000
  Call trace:
   iomap_iter_done+0x148/0x190 (P)
   iomap_iter+0x174/0x230
   iomap_fiemap+0x154/0x1d8
   ext4_fiemap+0x110/0x140 [ext4]
   do_vfs_ioctl+0x4b8/0xbc0
   __arm64_sys_ioctl+0x8c/0x120
   invoke_syscall+0x6c/0x100
   el0_svc_common.constprop.0+0x48/0xf0
   do_el0_svc+0x24/0x38
   el0_svc+0x38/0x120
   el0t_64_sync_handler+0x10c/0x138
   el0t_64_sync+0x198/0x1a0
  ---[ end trace 0000000000000000 ]---

Cc: stable@kernel.org
Fixes: facab4d ("ext4: return hole from ext4_map_blocks()")
Reported-by: Qu Wenruo <wqu@suse.com>
Closes: https://lore.kernel.org/linux-ext4/9b650a52-9672-4604-a765-bb6be55d1e4a@gmx.com/
Tested-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Zhang Yi <yi.zhang@huawei.com>
Link: https://patch.msgid.link/20250811064532.1788289-1-yi.zhang@huaweicloud.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
@sterling-teng
Copy link
Contributor

开发树已经变基,请尽快 rebase。

mainline inclusion
from mainline-v6.8-rc3
commit e33758f
category: feature
bugzilla: RVCK-Project#127

--------------------------------

For code unification, add emit_sextw wrapper to unify all the 32-bit
sign-extension operations.

Signed-off-by: Pu Lehui <pulehui@huawei.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Tested-by: Björn Töpel <bjorn@rivosinc.com>
Acked-by: Björn Töpel <bjorn@kernel.org>
Link: https://lore.kernel.org/bpf/20240115131235.2914289-2-pulehui@huaweicloud.com
Signed-off-by: gaorui <gao.rui@zte.com.cn>
mainline inclusion
from mainline-v6.8-rc3
commit 914c7a5
category: feature
bugzilla: RVCK-Project#127

--------------------------------

For code unification, add emit_zextw wrapper to unify all the 32-bit
zero-extension operations.

Signed-off-by: Pu Lehui <pulehui@huawei.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Tested-by: Björn Töpel <bjorn@rivosinc.com>
Acked-by: Björn Töpel <bjorn@kernel.org>
Link: https://lore.kernel.org/bpf/20240115131235.2914289-3-pulehui@huaweicloud.com
Signed-off-by: gaorui <gao.rui@zte.com.cn>
mainline inclusion
from mainline-v6.8-rc3
commit 361db44
category: feature
bugzilla: RVCK-Project#127

--------------------------------

There are many extension helpers in the current branch instructions, and
the implementation is a bit complicated. We simplify this logic through
two simple extension helpers with alternate register.

Signed-off-by: Pu Lehui <pulehui@huawei.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Tested-by: Björn Töpel <bjorn@rivosinc.com>
Acked-by: Björn Töpel <bjorn@kernel.org>
Link: https://lore.kernel.org/bpf/20240115131235.2914289-4-pulehui@huaweicloud.com
Signed-off-by: gaorui <gao.rui@zte.com.cn>
mainline inclusion
from mainline-v6.8-rc3
commit 647b93f
category: feature
bugzilla: RVCK-Project#127

--------------------------------

Add necessary Zbb instructions introduced by [0] to reduce code size and
improve performance of RV64 JIT. Meanwhile, a runtime deteted helper is
added to check whether the CPU supports Zbb instructions.

Signed-off-by: Pu Lehui <pulehui@huawei.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Tested-by: Björn Töpel <bjorn@rivosinc.com>
Acked-by: Björn Töpel <bjorn@kernel.org>
Link: https://github.com/riscv/riscv-bitmanip/releases/download/1.0.0/bitmanip-1.0.0-38-g865e7a7.pdf [0]
Link: https://lore.kernel.org/bpf/20240115131235.2914289-5-pulehui@huaweicloud.com
Signed-off-by: gaorui <gao.rui@zte.com.cn>
mainline inclusion
from mainline-v6.8-rc3
commit 519fb72
category: feature
bugzilla: RVCK-Project#127

--------------------------------

Add 8-bit and 16-bit sign-extention wraper with Zbb support to optimize
sign-extension mov instructions.

Signed-off-by: Pu Lehui <pulehui@huawei.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Tested-by: Björn Töpel <bjorn@rivosinc.com>
Acked-by: Björn Töpel <bjorn@kernel.org>
Link: https://lore.kernel.org/bpf/20240115131235.2914289-6-pulehui@huaweicloud.com
Signed-off-by: gaorui <gao.rui@zte.com.cn>
mainline inclusion
from mainline-v6.8-rc3
commit 06a33d0
category: feature
bugzilla: RVCK-Project#127

--------------------------------

Optimize bswap instructions by rev8 Zbb instruction conbined with srli
instruction. And Optimize 16-bit zero-extension with Zbb support.

Signed-off-by: Pu Lehui <pulehui@huawei.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Tested-by: Björn Töpel <bjorn@rivosinc.com>
Acked-by: Björn Töpel <bjorn@kernel.org>
Link: https://lore.kernel.org/bpf/20240115131235.2914289-7-pulehui@huaweicloud.com
Signed-off-by: gaorui <gao.rui@zte.com.cn>
mainline inclusion
from mainline-v6.10-rc1
commit c12603e
category: feature
bugzilla: RVCK-Project#127

--------------------------------

The Zba extension provides add.uw insn which can be used to implement
zext.w with rs2 set as ZERO.

Signed-off-by: Xiao Wang <xiao.w.wang@intel.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Tested-by: Pu Lehui <pulehui@huawei.com>
Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
Reviewed-by: Pu Lehui <pulehui@huawei.com>
Link: https://lore.kernel.org/bpf/20240516090430.493122-1-xiao.w.wang@intel.com
Signed-off-by: gaorui <gao.rui@zte.com.cn>
mainline inclusion
from mainline-v6.10-rc2
commit 96a27ee
category: feature
bugzilla: RVCK-Project#127

--------------------------------

Zba extension is very useful for generating addresses that index into array
of basic data types. This patch introduces sh2add and sh3add helpers for
RV32 and RV64 respectively, to accelerate addressing for array of unsigned
long data.

Signed-off-by: Xiao Wang <xiao.w.wang@intel.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Björn Töpel <bjorn@kernel.org>
Link: https://lore.kernel.org/bpf/20240524075543.4050464-3-xiao.w.wang@intel.com
Signed-off-by: gaorui <gao.rui@zte.com.cn>
@github-actions
Copy link

github-actions bot commented Oct 9, 2025


开始测试 log: https://github.com/RVCK-Project/rvck/actions/runs/18363540748

参数解析结果
args value
repository RVCK-Project/rvck
head ref pull/128/head
base ref rvck-6.6
LAVA repo RVCK-Project/lavaci
LAVA Template lava-job-template/qemu/qemu-ltp.yaml
Testcase path lava-testcases/common-test/ltp/ltp.yaml

测试完成

详细结果:

RVCK result

check result
kunit-test success
kernel-build success
lava-trigger success
check-patch success

Kunit Test Result

[02:26:58] Testing complete. Ran 455 tests: passed: 443, skipped: 12

Kernel Build Result

Kernel build succeeded: RVCK-Project/rvck/128/

c8d5cc83145cca86f6007f19e8520666 /srv/guix_result/d18d8d85ee5e830e68e94fa245897cfaa4a31e6a/Image
00e0fe1415682c350f6424f3eaa12859 /root/initramfs.img

LAVA Check

args:

result:

Lava check done! lava log: https://lava.oerv.ac.cn/scheduler/job/815

lava result count: [fail]: 175, [pass]: 1433, [skip]: 291

Check Patch Result

Total Errors 0
Total Warnings 8

@sterling-teng
Copy link
Contributor

为 RV64 JIT 添加 Zbb 支持,以优化代码大小和性能。同时,对代码进行调整以实现统一和简化。合入以下补丁

06a33d0 riscv, bpf: Optimize bswap insns with Zbb support 519fb72 riscv, bpf: Optimize sign-extention mov insns with Zbb support 647b93f riscv, bpf: Add necessary Zbb instructions 361db44 riscv, bpf: Simplify sext and zext logics in branch instructions 914c7a5 riscv, bpf: Unify 32-bit zero-extension to emit_zextw e33758f riscv, bpf: Unify 32-bit sign-extension to emit_sextw

RISC-V 的 Zba 扩展提供了用于加速对基本数据类型数组进行索引的地址生成的指令。通过利用 Zba 进行地址计算,可以减少 BPF JIT 生成的指令数量。

第一个补丁引入了 RISCV_ISA_ZBA Kconfig 选项,并使用 Zba 的 add.uw 指令来优化 zextw 操作。 c12603e riscv, bpf: Optimize zextw insn with Zba extension

第二个补丁使用 Zba 的移位和加法指令来优化对无符号长整型数据数组的地址计算。 96a27ee riscv, bpf: Introduce shift add helper with Zba optimization

测试方法: 使用内核自带的测试模块 test_bpf.ko 和 test_verifier, 运行相关测试用例 test_progs

内容是不是需要更新了?请引用下对用的issue。

@uestc-gr
Copy link
Contributor Author

为 RV64 JIT 添加 Zbb 支持,以优化代码大小和性能。同时,对代码进行调整以实现统一和简化。合入以下补丁
06a33d0 riscv, bpf: Optimize bswap insns with Zbb support 519fb72 riscv, bpf: Optimize sign-extention mov insns with Zbb support 647b93f riscv, bpf: Add necessary Zbb instructions 361db44 riscv, bpf: Simplify sext and zext logics in branch instructions 914c7a5 riscv, bpf: Unify 32-bit zero-extension to emit_zextw e33758f riscv, bpf: Unify 32-bit sign-extension to emit_sextw
RISC-V 的 Zba 扩展提供了用于加速对基本数据类型数组进行索引的地址生成的指令。通过利用 Zba 进行地址计算,可以减少 BPF JIT 生成的指令数量。
第一个补丁引入了 RISCV_ISA_ZBA Kconfig 选项,并使用 Zba 的 add.uw 指令来优化 zextw 操作。 c12603e riscv, bpf: Optimize zextw insn with Zba extension
第二个补丁使用 Zba 的移位和加法指令来优化对无符号长整型数据数组的地址计算。 96a27ee riscv, bpf: Introduce shift add helper with Zba optimization
测试方法: 使用内核自带的测试模块 test_bpf.ko 和 test_verifier, 运行相关测试用例 test_progs

内容是不是需要更新了?请引用下对用的issue。

已完成合入,请评审 #127

@sterling-teng
Copy link
Contributor

物理机测试通过

@sterling-teng sterling-teng merged commit 0b4b71d into RVCK-Project:rvck-6.6 Oct 22, 2025
49 checks passed
@uestc-gr uestc-gr deleted the bpf branch November 3, 2025 08:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants